Skip to content

feat: Add github_repository_pull_request_creation_policy resource#3349

Open
RoFz wants to merge 2 commits intointegrations:mainfrom
RoFz:feat/pull-request-creation-policy
Open

feat: Add github_repository_pull_request_creation_policy resource#3349
RoFz wants to merge 2 commits intointegrations:mainfrom
RoFz:feat/pull-request-creation-policy

Conversation

@RoFz
Copy link
Copy Markdown

@RoFz RoFz commented Apr 19, 2026

Resolves #3348


Before the change?

  • github_repository could not manage pull_request_creation_policy.
  • Users who needed to enforce it had to rely on out-of-band API calls or local workarounds.

After the change?

  • Add a new github_repository_pull_request_creation_policy resource that manages the pull request creation policy for a repository via the GitHub GraphQL API.
  • Support the all and collaborators_only values.
  • The resource reads and updates the setting through the GitHub GraphQL API and supports import by repository name.

Why a separate resource?

github_repository uses only the REST API. Because pullRequestCreationPolicy is only exposed via GraphQL, this change follows the existing pattern used by other GraphQL-backed resources in this provider (e.g. github_team_settings, github_branch_protection) and introduces a dedicated resource rather than mixing transport layers in github_repository.

Evidence

  • go test ./github -run 'TestPullRequestCreationPolicyMapping|TestRepositoryPullRequestCreationPolicyGraphQL' -count=1
  • make test
  • GH_TEST_AUTH_MODE=individual GITHUB_OWNER=RoFz GITHUB_USERNAME=RoFz make testacc T='TestAccGithubRepositoryPullRequestCreationPolicy'
  • make lintcheck
  • Manual test with a local provider override on disposable repo tf-pr-creation-policy-manual-20260419-120606: terraform apply succeeded, GitHub API readback returned collaborators_only, and a follow-up terraform plan -detailed-exitcode returned no changes.

Pull request checklist

  • Schema migrations have been created if needed
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

  • Yes
  • No

@github-actions
Copy link
Copy Markdown

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@github-actions github-actions Bot added the Type: Feature New feature or request label Apr 19, 2026
@RoFz RoFz force-pushed the feat/pull-request-creation-policy branch from 6f14748 to 4d4fe11 Compare April 19, 2026 11:38
@RoFz RoFz changed the title Add pull_request_creation_policy to github_repository feat: Add pull_request_creation_policy to github_repository Apr 19, 2026
@RoFz RoFz marked this pull request as ready for review April 19, 2026 11:41
Copy link
Copy Markdown
Collaborator

@deiga deiga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The github_repository resource relies solely on the REST API currently. If you need to use GQL API, then please do that in a separate resource.

RoFz added 2 commits April 21, 2026 19:49
- refactor: extract pull_request_creation_policy into github_repository_pull_request_creation_policy resource
- refactor: revert pull_request_creation_policy field and GraphQL calls from github_repository
- refactor: remove isUnsupportedPullRequestCreationPolicyError; dedicated resource fails loudly on missing API field
- feat: add github_repository_pull_request_creation_policy resource with GraphQL CRUD and import
- test: add acceptance tests for github_repository_pull_request_creation_policy
- docs: add documentation for github_repository_pull_request_creation_policy
@RoFz RoFz force-pushed the feat/pull-request-creation-policy branch from 4d4fe11 to efeb9d4 Compare April 21, 2026 18:50
@RoFz RoFz changed the title feat: Add pull_request_creation_policy to github_repository feat: Add github_repository_pull_request_creation_policy resource Apr 21, 2026
Copy link
Copy Markdown
Author

@RoFz RoFz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. Reworked to a dedicated github_repository_pull_request_creation_policy resource that uses only the GraphQL API, keeping github_repository REST-only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT]: support pull_request_creation_policy on github_repository

2 participants